package com.woniu.immunologicalmechanism.controller;

import com.woniu.common.entity.Organization;
import com.woniu.common.entity.ResponseResult;
import com.woniu.immunologicalmechanism.service.OrganizationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequestMapping("organization")
@Api(tags = "机构免疫信息登记修改接口")
@RestController
public class OrganizationController {
    @Autowired
    OrganizationService organizationService;

    @ApiOperation("添加机构")
    @PostMapping("/add")
    public ResponseResult add(Organization organization){

       return organizationService.addorganization(organization);
    }
    @ApiOperation("修改机构信息")
    @PostMapping("/update")
    public ResponseResult update(Organization organization){

       return organizationService.updateorganization(organization);
    }

    @ApiOperation("删除免疫机构")
    @PostMapping("/delete")
    public ResponseResult delete(int oid){

        return organizationService.deleteorganization(oid);
    }
    @ApiOperation("根据id查询免疫机构信息")
    @PostMapping("/get")
    public ResponseResult<Organization> getorganizationByoid(int oid){

        return organizationService.selectOrganization(oid);
    }
    @ApiOperation("根据名字模糊查询所有免疫机构信息")
    @PostMapping("/getall")
    public ResponseResult<List<Organization>> getorganizationByoname(String oname){

        return organizationService.selectOrganizationByname(oname);
    }


    @ApiOperation("根据uid查询免疫机构信息")
    @GetMapping("/getOrganizationByuid")
    public ResponseResult<List<Organization>> getorganizationByuid(int uid){
        System.out.println(uid);
        return organizationService.getOrganizationByuid(uid);
    }
}